import axios from '../http'

const api = '/api/categories/categories';

const brandsApi = '/api/brands';

const error = (e) => {
  return () => console.error(e);
};

export function listCategory(cb, fcb = error('listCategory')) {
  axios.get(api).then(d => cb(d.data)).catch(d => fcb(d))
}

export function listBrands(cid, cb, fcb = error('listBrands')) {
  axios.get(`${brandsApi}?categoryId=${cid}`).then(d => cb(d.data)).catch(d => fcb(d))
}